package com.hainatong.shiphelper.widget.recycleviewdriver;

import android.graphics.Rect;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class ListItemDecoration extends RecyclerView.ItemDecoration
{

    private int dividerColor;

    private int dividerHeight;

    public ListItemDecoration(int dividerHeight)
    {
        this.dividerHeight = dividerHeight;
    }

    public ListItemDecoration(int dividerColor, int dividerHeight)
    {
        this.dividerColor = dividerColor;
        this.dividerHeight = dividerHeight;
    }

    @Override
    public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state)
    {
         outRect.set(0,0,0,dividerHeight);
         if( parent.getChildAdapterPosition( view ) == 0 )
         {
             outRect.top = dividerHeight;
         }
    }
}
